
#if !defined(AFX_COMMONDEF_H__87E667A1_FD93_47CA_AD51_E0185DBAD573__INCLUDED_)
#define AFX_COMMONDEF_H__87E667A1_FD93_47CA_AD51_E0185DBAD573__INCLUDED_

#define GYWA_HELP_INDEX_FILE		_T("Index.htm")
#define	GYWA_INI_FILE				_T("GYWalkAid.ini")

#define	MAX_SUPPORT_WA_COUNT		5

#define ACTIVE_TAB_COLOR			RGB(180, 255, 255)
#define ACTIVE_TAB_COLOR2			RGB(255, 190, 255)


#define MAX_WRITE_PARAM_TIMES		5

#define WRITE_WA_MORE_TIMES(bOK, cmdWriteWA)									\
{																				\
	int wwmt_nWriteTimes = 0;													\
	BOOL wwmt_bWriteOK = FALSE;													\
	while(!wwmt_bWriteOK && wwmt_nWriteTimes < MAX_WRITE_PARAM_TIMES)			\
	{																			\
		wwmt_bWriteOK = (cmdWriteWA);											\
																				\
		wwmt_nWriteTimes++;														\
		if(!wwmt_bWriteOK && wwmt_nWriteTimes < MAX_WRITE_PARAM_TIMES)			\
			Sleep(300);															\
	}																			\
	bOK = wwmt_bWriteOK;														\
}																				\


enum INPUT_BOX_TYPE
{
	IBT_NoneType	= 0x00000000,
	IBT_EditBox		= 0x00000001,
	IBT_EditDate	= 0x00000002,
	IBT_ComboBox	= 0x00000004,
	IBT_Bttton		= 0x00000008,

	IBT_AllType		= 0xFFFFFFFF,
};


#define IsNumInRange(nNum, nMin, nMax)	((nNum) >= (nMin) && (nNum) <= (nMax))


#define ARRAY_ELE_COUNT(arr)			(sizeof(arr)/sizeof(arr[0]))
#define ZERO_ARRAY(arr)					memset(arr, 0, sizeof(arr));

#ifndef SAFE_DELETE
#define SAFE_DELETE(p)					{if(p){delete (p); (p) = NULL;}}
#endif

#define NULL_RETURN_FALSE(p)			if(NULL==(p)){return FALSE;}
#define NULL_RETURN_ZERO(p)				if(NULL==(p)){return 0;}
#define NULL_RETURN_EMPTY(p)			if(NULL==(p)){return _T("");}

#define CLOSE_HANDLE(h)					if(h){CloseHandle(h);(h)=NULL;}

#define IsKeyDown(key)					(GetKeyState(key) < 0)

enum
{
	ftString = 0,
	ftNumber,
	ftDate,
};

typedef BOOL (*FIELD_CHECK_FUNC)(LPVOID pParam);

typedef struct tagINPUT_FIELD_INFO
{
	LPVOID				pLinkCtrl;
	DWORD				dwCtrlType;
	BOOL				bAlwaysReadOnly;
	BOOL				bCustMsgProc;
	TCHAR				szFieldName[MAX_PATH];
	DWORD				dwFieldType;
	BOOL				bAllowEmpty;
	DWORD				dwFieldDescStringID;
	int					nMaxLength;
	FIELD_CHECK_FUNC	FieldCheckFunc;
	FIELD_CHECK_FUNC	KillFocusCheckFunc;
}INPUT_FIELD_INFO;

#define MAX_CONNECT_COUNT	8
#define MAX_SERVICE_COUNT	100

typedef struct _COD_DESC
{
	DWORD dwValue;
	TCHAR *lpszDesc;
}COD_DESC;

#define		MAX_OPEN_CLOSE_VALUE				192
#define		MIN_OPEN_CLOSE_VALUE				64

#define		MYSQL_REG_KEY_PATH					_T("SOFTWARE\\MySQL AB\\MySQL Server 5.5")
#define		MYSQL_REG_KEY_NAME					_T("Location")


#define		USER_ROLE_COMMON_DOCTOR				0
#define		USER_ROLE_HOSPITAL_ADMIN			1
#define		USER_ROLE_GY_ADMIN					2

#define GYWA_MSG_BLUETOOTH_DEVICE_CONNECTED					(WM_USER + 1000)
#define GYWA_MSG_BLUETOOTH_CONNECT_PROGRESS					(WM_USER + 1001)
#define GYWA_MSG_BLUETOOTH_FOUND_NEWDEV						(WM_USER + 1002)
#define GYWA_MSG_BLUETOOTH_REMOVE_DEV						(WM_USER + 1003)
#define GYWA_MSG_BLUETOOTH_CONNECT_FAIL						(WM_USER + 1004)
#define GYWA_MSG_BLUETOOTH_TIMERID_INQUIRE_WA				(WM_USER + 1005)

#define GYWA_MSG_REALTIME_TIMERID_SHOWTIME					(WM_USER + 1010)
#define GYWA_MSG_REALTIME_TIMERID_REFRESH_WACOUNT			(WM_USER + 1011)
#define GYWA_MSG_REALTIME_OPEN_CLOSE_VALUE					(WM_USER + 1012)
#define GYWA_MSG_REALTIME_TIMERID_HIDE_LABEL				(WM_USER + 1013)

#define GYWA_MSG_NAVI_TIMERID_BT_COMPLETED					(WM_USER + 1020)
#define GYWA_MSG_1STDIAG_TIMERID_SHOWGAIT					(WM_USER + 1021)
#define GYWA_MSG_SDIAG_TIMERID_SHOWGAIT						(WM_USER + 1022)
#define GYWA_MSG_SYS_TIMERID_SHOWWACOLOR					(WM_USER + 1023)
#define GYWA_MSG_NAVI_AUTO_BACKUP_DB						(WM_USER + 1024)


#endif//AFX_COMMONDEF_H__87E667A1_FD93_47CA_AD51_E0185DBAD573__INCLUDED_

